﻿Imports System.Data.SqlClient
Public Class frmSalariosMinimos

    Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
        Close()

    End Sub

    Private Sub frmSalariosMinimos_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        SM()

    End Sub
    Sub SM()
        dgSM.Rows.Clear()

        Dim cnconn As New SqlConnection
        cnconn.ConnectionString = CitraConnection

        Dim strSql As String = "SELECT * FROM SalariosMinimos"

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnconn
        cmdBuscar.CommandText = strSql

        Dim rdBuscar As SqlDataReader
        cnconn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Do While rdBuscar.Read()
            dgSM.Rows.Add(rdBuscar("IdSM"), rdBuscar("zona"), rdBuscar("monto"))

        Loop
    End Sub

    Private Sub RadButton2_Click(sender As System.Object, e As System.EventArgs) Handles RadButton2.Click
        Dim i As Integer
        Dim SM As New clsSM
        For i = 0 To dgSM.Rows.Count - 1
            SM.IdSM = dgSM.Rows(i).Cells(0).Value
            SM.Monto = dgSM.Rows(i).Cells(2).Value
            SM.Actualizar()
        Next
        Close()

    End Sub
End Class